package net.hxz.modules.controller.frontEnd;

import net.hxz.modules.controller.BaseController;
import net.hxz.modules.services.IBannerService;
import net.hxz.modules.services.INewsService;
import net.hxz.modules.services.ITextService;
import net.hxz.modules.services.ITypeService;
import net.wy.myBatisPlugin.page.model.PageRowBounds;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 网站统一入口
 * @author OYJ
 */
@Controller
@RequestMapping(value="/{lang}/")
public class CoreController extends BaseController {

	@Autowired
	private IBannerService bannerService;
	
	@Autowired
	private ITextService textService;
	
	@Autowired
	private ITypeService typeService;
	
	@Autowired
	private INewsService newsService;
	
	@RequestMapping("index")
	public String index(@PathVariable String lang, ModelMap map, PageRowBounds page) {
		map.put("list", bannerService.list());
		map.put("types", typeService.getByParent(0L));
		map.put("news", newsService.list(page));
		
		map.put("lang", lang.equals("en") ? 0 : 1);
		map.put("jsp", "core/index");
		return PHONE_MAIN_PATH;
	}
	
}
